﻿@{
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<html>
<head>
    <script type="text/javascript">
        $(function () {
            $('#ff').form('load', '/User/GetUserById/?id=@TempData["uId"]');
            $("#PrimaryPhoneNumber").mask("(999) 999-9999");
        });

        function saveUser() {
            var postdata = {
                UserId: $("#UserId").val(),
                FirstName: $("#FirstName").val(),
                LastName: $("#LastName").val(),
                ZipCode: $("#ZipCode").val(),
                CompanyName: $("#CompanyName").val(),
                PrimaryPhoneNumber: $("#PrimaryPhoneNumber").val(),
                AltPhoneNumber: $("#AltPhoneNumber").val()
            };
            $.ajax({
                type: "POST",
                url: '/User/UpdateUser',
                data: postdata,
                beforeSend: function () {
                    return $('#ff').form('validate');
                },
                success: function (result) {
                    if (result.Success) {
                        $('#ff').form('load', '/User/GetUserById/?id=@TempData["uId"]&ts='+$time());
                        $.messager.alert("Message", result.Message);
                    } else {
                        $.messager.show({
                            title: 'Error',
                            msg: result.Message
                        });
                    }
                }
            });
        }
    </script>
</head>
<body>
    <div class="easyui-panel" title="My Profile" style="height: 500px" iconCls="icon-ok">
        <div style="padding: 10px 0 10px 60px">
            <form id="ff" method="post" novalidate>
                <input id="UserId" name="UserId" type="hidden" />
                <table>
                    <tr>
                        <td>First Name:</td>
                        <td>
                            <input class="easyui-validatebox" type="text" id="FirstName" name="FirstName" data-options="required:true"></input></td>
                    </tr>
                    <tr>
                        <td>Last Name:</td>
                        <td>
                            <input class="easyui-validatebox" type="text" id="LastName" name="LastName" data-options="required:true"></input></td>
                    </tr>
                    @*<tr>
                        <td>Email:</td>
                        <td>
                            <input class="easyui-validatebox" type="text" id="Email" name="Email" data-options="required:true,validType:'email'"></input></td>
                    </tr>*@
                    <tr>
                        <td>Company Name:</td>
                        <td>
                            <input class="easyui-validatebox" type="text" id="CompanyName" name="CompanyName" data-options="required:false"></input></td>
                    </tr>
                    <tr>
                        <td>Zip Code:</td>
                        <td>
                            <input id="ZipCode" id="ZipCode" name="ZipCode" class="easyui-validatebox" required="true">
                        </td>
                    </tr>
                    <tr>
                        <td>Phone:</td>
                        <td>
                            <input class="easyui-validatebox" type="text" id="PrimaryPhoneNumber" name="PrimaryPhoneNumber" data-options="required:false"></input></td>
                    </tr>
                   @* <tr>
                        <td>Altnate PhoneNumber:</td>
                        <td>
                            <input class="easyui-validatebox" type="text" id="AltPhoneNumber" name="AltPhoneNumber" data-options="required:true"></input></td>
                    </tr>*@
                    <tr>
                        <td colspan="2" style="text-align:center;padding-top: 10px">
                            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveUser()">Save</a>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</body>
</html>

